package com.caius.framework.common.util;

import java.math.RoundingMode;
import java.text.DecimalFormat;

/**
 * @author Caius
 * @description
 * @since Created in 2025-05-31
 */
public class NumberUtils {

    /**
     * 数字转字符串
     * @param number
     * @return
     */
    public static String formatNumberString(long number) {
        if (number < 10000) {
            return String.valueOf(number);
        } else if(number > 10000 && number < 100000000){
            double result = number / 10000.0;
            DecimalFormat df = new DecimalFormat("#.#");
            df.setRoundingMode(RoundingMode.DOWN); //禁用四舍五入
            String formatted = df.format(result);
            return formatted + "万";
        } else {
            return "9999万";  // 超过 1 亿，统一显示 9999万
        }
    }

}
